package com.safetyprotectiondemo;

import android.util.Log;

import com.safetyprotection.App;
import com.safetyprotection.AppFlyer.AppsFlyerCallBase;
import com.safetyprotection.SafetyProtectionManageD.Bean.SafetyProtectionBean;
import com.safetyprotection.SafetyProtectionManageD.SafetyProtectionManage;
import com.safetyprotection.SpUtil.SpUtil;

import java.util.HashMap;

public class APPDemo extends App {
    public static String value;

    public static boolean isShow = false;
    public static isshow isshow1;

    @Override
    public void onCreate() {
        super.onCreate();
        SafetyProtectionManage.getInstance()

                .setAF_DEV_KEY("65KGjam4H3ZB5GVdDEmpp6") // 动态设置AppFlyer 的 AF_DEV_KEY

                .initAppsflyer(this, new AppsFlyerCallBase() {
                    @Override
                    public void OnCallBack(SafetyProtectionBean mSafetyProtectionBean) {
                        Log.d("LOG_TAG", "safetyProtectionData: " + mSafetyProtectionBean.toString());
                        String url;
                        try {
                            url = SafetyProtectionManage.getInstance().buildUrlFromBean(mSafetyProtectionBean);
                        } catch (IllegalAccessException e) {
                            throw new RuntimeException(e);
                        }
                        SpUtil.putString(getContext(), "value", url);
                        isshow1.isShow();
                        isShow = true;
                    }
                }) // 初始化归因Appsflyer,并且可拿到整理好的安防数据,并且通过SafetyProtectionManage.getInstance().buildUrlFromBean方法将数据转换成URL拼参数。
                .IslocationTaskEnabled(true) // 是否开启地理围栏 如开启地理围栏Activity需基础BaseActivity类，以获取定位权限
                .Logevent("ss", new HashMap<>());
    }

    public static void setIsShow(isshow Show) {
        isshow1 = Show;
    }

    public interface isshow {
        void isShow();
    }

    public static String getValue() {
        return value;
    }

}
